aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/(profile)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-05 19:20:36 -0800
committerAdam Soltys <[email protected]>2024-12-05 19:20:36 -0800
commita9b44cbae79e9c01cff07964a45e1c7efa7fb241 (patch)
tree5caa996fc2eca705fb793e79d63bfbf5f9f93e48 /src/routes/(app)/[username]/(profile)
parent6422ef30f14e1baf5d1995de69c777efcad77e32 (diff)
downloadcoinos-ui-a9b44cbae79e9c01cff07964a45e1c7efa7fb241.tar.gz
coinos-ui-a9b44cbae79e9c01cff07964a45e1c7efa7fb241.zip
cached rates
Diffstat (limited to 'src/routes/(app)/[username]/(profile)')
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.server.ts4
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte6
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.server.ts8
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.svelte4
4 files changed, 13 insertions, 9 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+layout.server.ts b/src/routes/(app)/[username]/(profile)/+layout.server.ts
index 0ed3edb8..70e7ebdb 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.server.ts
+++ b/src/routes/(app)/[username]/(profile)/+layout.server.ts
@@ -1,8 +1,10 @@
+import getRates from "$lib/rates";
import { get } from "$lib/utils";
export async function load({ depends, parent }) {
depends("app:user");
+ const rates = await getRates();
const { subject, user } = await parent();
const { follows, followers } = await get(`/${subject.pubkey}/count`);
@@ -12,5 +14,5 @@ export async function load({ depends, parent }) {
() => [],
);
- return { follows, followers, followList };
+ return { follows, followers, followList, rate: rates[subject.currency] };
}
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index 98d4238b..3887d026 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -25,10 +25,10 @@
let {
events,
+ rate,
user,
subject,
src,
- rates,
text,
follows,
followers,
@@ -292,13 +292,13 @@
<div class="my-auto mr-1">1</div>
<img src="/images/bitcoin.svg" class="w-5 my-auto" alt="Bitcoin" />
</div>
- <div>&#61; {f(rates[currency], currency, locale, 0, 0)}</div>
+ <div>&#61; {f(rate, currency, locale, 0, 0)}</div>
</div>
<div class="text-secondary flex ml-auto">
<div class="flex items-center">
<iconify-icon icon="ph:lightning-fill" class="text-yellow-300"
></iconify-icon>
- {s((1 * sats) / rates[currency])} =
+ {s((1 * sats) / rate)} =
{f(1, currency, locale, 0, 0)}
</div>
</div>
diff --git a/src/routes/(app)/[username]/(profile)/+page.server.ts b/src/routes/(app)/[username]/(profile)/+page.server.ts
index a7fb4f19..5f0e7579 100644
--- a/src/routes/(app)/[username]/(profile)/+page.server.ts
+++ b/src/routes/(app)/[username]/(profile)/+page.server.ts
@@ -1,11 +1,15 @@
+import getRates from "$lib/rates";
import { auth, get } from "$lib/utils";
-export async function load({ cookies, depends }) {
+export async function load({ cookies, depends, parent }) {
depends("app:payments");
depends("app:items");
+ const { subject } = await parent();
+
let accounts = [];
if (cookies.get("token")) accounts = await get("/accounts", auth(cookies));
- return { accounts };
+ const rates = await getRates();
+ return { accounts, rate: rates[subject.currency] };
}
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte
index eb21a45c..25728372 100644
--- a/src/routes/(app)/[username]/(profile)/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/+page.svelte
@@ -14,9 +14,7 @@
preloadData("/send");
});
- let { accounts, subject, user, rates } = $state(data);
- let { currency } = $derived(subject);
- let rate = $derived(rates[currency]);
+ let { accounts, subject, rate, user } = $state(data);
let install = async () => {
if (!$installPrompt) return;